# -*- coding:utf-8 -*-

from cgi import escape


def safe_data(data):
	if isinstance(data, dict):
		for k, v in data.items():
			if isinstance(data[k], unicode):
				data[k] = escape(v)
	elif isinstance(data, unicode):
		data = escape(data)
	return data
